{$layout "layout_popup"}

<h3>续期实例</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
    <csrf-token></csrf-token>
    <input type="hidden" name="userInstanceId" :value="userInstance.id"/>
    <input type="hidden" name="periodId" :value="selectedPeriodId"/>
    <table class="ui table definition selectable">
        <tr>
            <td class="title">用户</td>
            <td>
                <div v-if="userInstance.user.id > 0"><user-link :v-user="userInstance.user"></user-link></div>
                <span v-else class="red">已删除</span>
            </td>
        </tr>
        <tr>
            <td>高防产品</td>
            <td>
                <div v-if="userInstance.package.id > 0">{{userInstance.package.summary}}</div>
                <span v-else class="red">已删除</span>
            </td>
        </tr>
        <tr>
            <td>高防IP</td>
            <td>
                <div v-if="userInstance.instance.id > 0">
                    <div v-for="ip in userInstance.instance.ipAddresses">{{ip}}</div>
                </div>
                <span v-else class="red">已删除</span>
            </td>
        </tr>
        <tr>
            <td>当前有效期</td>
            <td>{{userInstance.dayTo}}
                <p class="comment" v-if="userInstance.isExpired">
                    <span class="red">已过期，续期后新的有效期将会从今天（{{userInstance.today}}）开始。</span>
                </p>
                <p class="comment" v-else>续期后，将会在此基础上增加新的有效期。</p>
            </td>
        </tr>
        <tr>
            <td>新续有效期 *</td>
            <td>
                <div v-if="allPeriods.length > 0">
                    <a v-for="period in allPeriods" class="ui label basic" :class="{blue: period.id == selectedPeriodId}" @click.prevent="selectPeriod(period.id)">{{period.count}}{{period.unitName}}</a>
                </div>
                <span v-else class="red">没有可用的有效期</span>
            </td>
        </tr>
        <tr>
            <td>价格</td>
            <td>
                <span v-if="amount == 0" class="disabled">没有找到对应价格</span>
                <span v-if="amount > 0">{{amount}}元</span>
                <p class="comment">管理员操作时，此价格仅供展示，并不会从用户账户中扣款。</p>
            </td>
        </tr>
    </table>
    <submit-btn v-if="amount > 0">续期</submit-btn>
</form>
